package com.nz2004.service.Impl;

import com.github.pagehelper.PageHelper;
import com.nz2004.entity.Menu;
import com.nz2004.entity.MyMsg;
import com.nz2004.mapper.MenuMapper;
import com.nz2004.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

@Service("MenuService")
public class MenuServiceImpl implements MenuService {

    @Autowired
    private MenuMapper menuMapper;

    @Override
    public List<Menu> queryMenuByUserId(Integer userId) {
        List<Menu> menus = menuMapper.queryMenuByUserId(userId);
        return menus;
    }

    @Override
    public MyMsg queryMenus(int pageNum, int pageSize) {
        MyMsg myMsg = new MyMsg();
        PageHelper.startPage(pageNum,pageSize);
        List<Menu> users = menuMapper.queryMenus();
        if(users == null){
            myMsg.setCode(1);
        }
        myMsg.setMsg("没有查询到呢");
        myMsg.setData(users);
        Long rows = menuMapper.queryCount();
        myMsg.setCount(rows);
        return myMsg;
    }


}
